{% extends "base.html" %}
{% load static %}

{% block content %}
<div class="row">
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
        修改客户信息
    </button>
    <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalCenterTitle">修改客户基本信息</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form method="post" action="{% url 'Kehu_detail' pk=object.id %}">
                        {% csrf_token %}
                        {{ kehu_form.as_p }}
                        <button type="submit" name="form_key" value="xinxi">更新客户信息</button>
                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存更改</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#genjinlogModal">
        添加跟进记录
    </button>
    <div class="modal fade" id="genjinlogModal" tabindex="-1" role="dialog" aria-labelledby="genjinlogModalTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="genjinlogModalTitle">添加跟进记录</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form method="post" action="{% url 'Kehu_detail' pk=object.id %}">
                        {% csrf_token %}
                        {{ genjinlog_form.as_p }}
                        <button type="submit" name="form_key" value="genjinlog">保存</button>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存更改</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ziliaoModal">
        添加客户资料
    </button>
    {% if form.errors %}
                          {{ form.errors }}
                        {% endif %}
    <div class="modal fade" id="ziliaoModal" tabindex="-1" role="dialog" aria-labelledby="ziliaoModalTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="ziliaoModalTitle">添加客户资料</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form method="post" action="{% url 'Kehu_detail' pk=object.id %}" enctype="multipart/form-data">
                        {% csrf_token %}
                        {{ KeHuzilao_Form.as_p }}
                        <button type="submit" name="form_key" value="ziliao">保存</button>
                    </form>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存更改</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#dingdanModal">
        添加订单
    </button>
    <div class="modal fade" id="dingdanModal" tabindex="-1" role="dialog" aria-labelledby="dingdanModalTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="dingdanModalTitle">添加订单</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form method="post" action="{% url 'Kehu_detail' pk=object.id %}">
                        {% csrf_token %}
                        {{ KeHuDingdan_Form.as_p }}
                        <button type="submit" name="form_key" value="dingdan">保存</button>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存更改</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 为其他表单类似地创建模态框 -->




{% endblock %}
{% block footerjs %}
<script>
document.addEventListener("DOMContentLoaded", function() {
  // 获取 URL 中的锚点部分
  var hash = window.location.hash;
  // 检查是否指定了有效的标签页 ID（去掉前面的 # 号）
  if (hash && hash.startsWith("#")) {
    var tabToShow = hash.substring(1); // 去掉 # 号
    $('a[href="#' + tabToShow + '"]').tab('show');
  }

});
</script>
{% endblock %}